package com.park.service.impl.book;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.park.client.model.book.BookModel;
import com.park.client.service.book.BookService;
import com.park.common.id.IdFactoryUtils;
import com.park.dao.book.BookMapper;
import com.park.service.impl.base.BaseServiceImpl;

@Service("bookService")
public class BookServiceImpl extends BaseServiceImpl<BookModel> implements BookService {
	
	@Autowired
	private BookMapper bookMapper;

	@Override
	public boolean insert(BookModel book) {
		return bookMapper.insert(book)==1 ;
	}
	@Override
	public boolean deleteByPrimaryKey(Long id) {
		return bookMapper.deleteByPrimaryKey(id)==1;
	}
	@Override
	public boolean insertSelective(BookModel record) {
		return bookMapper.insertSelective(record)==1;
	}
	@Override
	public BookModel selectByPrimaryKey(Long id) {
		return bookMapper.selectByPrimaryKey(id);
	}
	@Override
	public boolean updateByPrimaryKeySelective(BookModel record) {
		return bookMapper.updateByPrimaryKeySelective(record)==1;
	}
	@Override
	public boolean updateByPrimaryKey(BookModel record) {
		return bookMapper.updateByPrimaryKey(record)==1;
	}
	@Override
	public List<BookModel> selectAll() {
		return bookMapper.selectAll();
	}
	@Override
	public boolean updateByPrimaryKeyWithBLOBs(BookModel record) {
		return false;
	}
	@Override
	public List<BookModel> selectByList() {
		return bookMapper.selectByList();
	}
	@Override
	public List<BookModel> selectByUserId(Long userId) {
		return bookMapper.selectByUserId(userId);
	}
	@Override
	public List<BookModel> selectPagination(BookModel t) {
		return bookMapper.selectPagination(t);
	}
	@Override
	public Integer selectTotal(BookModel t) {
		return bookMapper.selectTotal(t);
	}
	
	@Override
	public void saveOrUpdate(BookModel book) {
		if(book == null){
			return;
		}
		if(book.getId() == null){
			book.setId(IdFactoryUtils.getId());
			this.insert(book);
		}else{
			this.updateByPrimaryKey(book);
		}
	}

}
